<template>
  <view class="profile-header">
    <view class="profile-bg">
      <!-- 背景装饰元素 -->
      <view class="cyber-line line1"></view>
      <view class="cyber-line line2"></view>
      <view class="cyber-circle"></view>
    </view>
    
    <view class="profile-content">
      <view class="avatar-container">
        <image :src="avatar" class="avatar" mode="aspectFill"></image>
        <view class="avatar-border"></view>
      </view>
      
      <view class="user-info">
        <view class="username-container">
          <text class="username">{{ username }}</text>
          <view class="level-badge">{{ level }}</view>
        </view>
        
        <view class="points-container">
          <text class="points-label">量子点数</text>
          <text class="points-value">{{ points }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
defineProps({
  avatar: {
    type: String,
    default: '/static/icons/default-avatar.png'
  },
  username: {
    type: String,
    default: 'CYBER_USER'
  },
  level: {
    type: String,
    default: 'BASIC'
  },
  points: {
    type: Number,
    default: 0
  }
});
</script>

<style>
.profile-header {
  position: relative;
  height: 180px;
  width: 100%;
  overflow: hidden;
  box-sizing: border-box;
}

.profile-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 1;
  box-sizing: border-box;
}

.cyber-line {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, #ff00ff, transparent);
}

.line1 {
  width: 80%;
  top: 40px;
  left: 10%;
  animation: glow 3s infinite alternate;
}

.line2 {
  width: 60%;
  bottom: 30px;
  right: 5%;
  background: linear-gradient(90deg, transparent, #00ffff, transparent);
  animation: glow 2.5s infinite alternate-reverse;
}

.cyber-circle {
  position: absolute;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 1px solid rgba(255, 0, 255, 0.3);
  top: -30px;
  right: -30px;
  animation: rotate 10s linear infinite;
}

.cyber-circle::after {
  content: '';
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 1px solid rgba(0, 255, 255, 0.3);
  top: 15px;
  left: 15px;
  animation: rotate 7s linear infinite reverse;
}

@keyframes glow {
  0% { opacity: 0.3; }
  100% { opacity: 0.8; }
}

@keyframes rotate {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.profile-content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  padding: 20px;
  height: 100%;
  box-sizing: border-box;
  width: 100%;
}

.avatar-container {
  position: relative;
  width: 80px;
  height: 80px;
  margin-right: 20px;
  flex-shrink: 0;
}

.avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid #00ffff;
}

.avatar-border {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 1px dashed rgba(255, 0, 255, 0.7);
  animation: rotate 10s linear infinite;
}

.user-info {
  flex: 1;
  min-width: 0; /* 防止flex子项超出容器 */
  overflow: hidden; /* 防止内容溢出 */
}

.username-container {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap; /* 允许在需要时换行 */
}

.username {
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  margin-right: 10px;
  text-shadow: 0 0 5px rgba(0, 255, 255, 0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.level-badge {
  background: linear-gradient(135deg, #ff00ff, #00ffff);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  color: #000;
  font-weight: bold;
  margin-top: 5px;
}

.points-container {
  display: flex;
  align-items: center;
  flex-wrap: wrap; /* 允许在需要时换行 */
}

.points-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  margin-right: 5px;
}

.points-value {
  font-size: 16px;
  color: #00ffff;
  font-weight: bold;
}
</style>
